#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: api001_connections.py 
@version:
@time: 2022/05/27 
"""
from TapClientCore.T02_tm_api.v2_api.v2_api_base import *


class Api001ConnectionsUrl(V2ApiUrlBase):
    url_connections = api_joint(V2ApiUrlBase().server, CONNECTIONS)


class Api001Connections(V2ApiBase, Api001ConnectionsUrl):

    # 查询
    def pdk_get_connections_by_filter(self, _filter):
        response = self.tapclient(
            self.get,
            self.url_connections
            + self.access_token
            + self.filter(_filter)
        )
        return response

    # 创建
    def pdk_post_connections(self, payload):
        response = self.tapclient(
            self.post,
            self.url_connections
            + self.access_token,
            json=payload
        )
        return response

    # 删除
    def pdk_delete_connections_by_name_and_id(self, _id, name):
        response = self.tapclient(
            self.delete,
            api_joint(
                self.url_connections,
                _id
            )
            + f'?name={name}'
            + self.access_token2
        )
        return response

    # 修改
    def pdk_patch_connections_by_id(self, _id, payload):
        response = self.tapclient(
            self.patch,
            api_joint(
                self.url_connections,
                _id
            )
            + self.access_token,
            json=payload
        )
        return response
